package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.dict.service.ITDictWorkOrderStatusService;
import com.ruoyi.dict.service.ITDictRptOrderStatusService;
import com.ruoyi.dict.service.ITDictAssetStatusService;
import com.ruoyi.dict.domain.TDictWorkOrderStatus;
import com.ruoyi.dict.domain.TDictRptOrderStatus;
import com.ruoyi.dict.domain.TDictAssetStatus;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 状态字典Controller
 * 
 * @author ruoyi
 * @date 2025-01-21
 */
@RestController
@RequestMapping("/system/status")
public class StatusController extends BaseController
{
    @Autowired
    private ITDictWorkOrderStatusService workOrderStatusService;
    
    @Autowired
    private ITDictRptOrderStatusService rptOrderStatusService;
    
    @Autowired
    private ITDictAssetStatusService assetStatusService;

    /**
     * 获取维修单状态列表
     */
    @GetMapping("/work-order/list")
    public TableDataInfo getWorkOrderStatusList(@RequestParam(defaultValue = "1") Integer pageNum,
                                           @RequestParam(defaultValue = "10") Integer pageSize,
                                           @RequestParam(required = false) Integer enabled)
    {
        startPage();
        TDictWorkOrderStatus query = new TDictWorkOrderStatus();
        if (enabled != null) {
            query.setEnabled(enabled);
        }
        List<TDictWorkOrderStatus> list = workOrderStatusService.selectTDictWorkOrderStatusList(query);
        return getDataTable(list);
    }

    /**
     * 获取报修单状态列表
     */
    @GetMapping("/rpt-order/list")
    public TableDataInfo getRptOrderStatusList(@RequestParam(defaultValue = "1") Integer pageNum,
                                          @RequestParam(defaultValue = "10") Integer pageSize,
                                          @RequestParam(required = false) Integer enabled)
    {
        startPage();
        TDictRptOrderStatus query = new TDictRptOrderStatus();
        if (enabled != null) {
            query.setEnabled(enabled);
        }
        List<TDictRptOrderStatus> list = rptOrderStatusService.selectTDictRptOrderStatusList(query);
        return getDataTable(list);
    }

    /**
     * 获取资产状态列表
     */
    @GetMapping("/asset/list")
    public TableDataInfo getAssetStatusList(@RequestParam(defaultValue = "1") Integer pageNum,
                                       @RequestParam(defaultValue = "10") Integer pageSize,
                                       @RequestParam(required = false) Integer enabled)
    {
        startPage();
        TDictAssetStatus query = new TDictAssetStatus();
        if (enabled != null) {
            query.setEnabled(enabled);
        }
        List<TDictAssetStatus> list = assetStatusService.selectTDictAssetStatusList(query);
        return getDataTable(list);
    }

    // 保留细分的列表接口：/work-order/list、/rpt-order/list、/asset/list
    // 注意：不再暴露通用的 /system/status/list 以避免与其他 Controller 冲突
}
